require.mx('mxjs/base/utilities/typed_array_extensions.js');
Adds convenience methods to the TypedArray types.
Status | Name |
---|
This library does not return anything (there is no need to save the result of the call to
require.mx()
). When the library is loaded, it will add methods to the
TypedArray
prototypes. So, simply
require.mx()
the library prior to attempting to use any of the extension methods.
A placeholder for all of the builtin
TypedArray
classes. That is, all of the methods listed for this class are in fact defined for each of the concrete
TypedArray
classes:
Int8Array
,
Uint8Array
,
Uint8ClampedArray
,
Int16Array
,
Uint16Array
,
Int32Array
,
Uint32Array
,
Float32Array
, and
Float64Array
.
Status | Name |
---|---|
Number countIf
(
Function callback,
Object thisArg
)
Count the number of elements in this TypedArray for which a given predicate returns true. |
|
find
(
Function callback,
Object thisArg
)
This is a polyfill, only added if the standard builtin method does not exist. You can read the definition of the builtin method at: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/find |
|
findIndex
(
Function callback,
Object thisArg
)
This is a polyfill, only added if the standard builtin method does not exist. You can read the definition of the builtin method at: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/findIndex |
|
forEach
(
Function callback,
Object thisArg
)
This is a polyfill, only added if the standard builtin method does not exist. You can read the definition of the builtin method at: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/forEach |
|
String join
(
String separator
)
This is a polyfill, only added if the standard builtin method does not exist. You can read the definition of the builtin method at: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/join |
|
type map
(
Function callback,
Object thisArg
)
This is a polyfill, only added if the standard builtin method does not exist. You can read the definition of the builtin method at: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/map |
|
type mapToType
(
Function type,
Function callback,
Object thisArg
)
This is analagous to TypedArray.prototype.map(), except that the type of the returned array is defined by the caller (in the first parameter). This is useful, for example, if you are mapping from an integer array to a float array. |
|
Object minMaxIndices
(
)
Find the indices of the minimum and maximum values in this TypedArray. |
|
Object minMaxValues
(
)
Find the minimum and maximum values of all elements in this TypedArray. |
|
TypedArray readFromColumn
(
Function readFn,
Number begin,
Number end,
Number defaultValue
)
This is a static method (it is called directly on the type, not on an object of that type, e.g.
|
|
TypedArray readFromColumnStrict
(
Function readFn,
Number begin,
Number end
)
This is a static method (it is called directly on the type, not on an object of that type, e.g.
|
|
? reduce
(
Function callback,
Object initialValue
)
This is a polyfill, only added if the standard builtin method does not exist. You can read the definition of the builtin method at: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/map |
|
type slice
(
Number begin,
Number end
)
This is a polyfill, only added if the standard builtin method does not exist. You can read the definition of the builtin method at: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice |
|
transform
(
Function ↓callback,
Object ↓thisArg
)
Transform each element of the TypedArray using the given callback function. This is equivalent to the code:
|
|
writeToColumn
(
Function writeFn,
Number offset
)
Writes the values in this array to a table column, using the provided write function. |
Count the number of elements in this TypedArray for which a given predicate returns true.
Parameters:Function
callback - the predicate, which receives three parameters: an element value, the index of the element, and this TypedArray; and must return a truthy value if the element should be counted.Object
thisArg - (optional) used as this
when calling the predicate function.Number
count - the number of elements for which the predicate returned a truthy valueThis is a polyfill, only added if the standard builtin method does not exist. You can read the definition of the builtin method at: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/join
Parameters:String
separator - (optional)String
result This is a polyfill, only added if the standard builtin method does not exist. You can read the definition of the builtin method at: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/map
Parameters: Returns:type
result - an array with the same type as this array, containing the values produced by the callback
function.This is analagous to TypedArray.prototype.map(), except that the type of the returned array is defined by the caller (in the first parameter). This is useful, for example, if you are mapping from an integer array to a float array.
Parameters:Function
type - a TypedArray type (e.g. Float64Array
).Function
callback Object
thisArg - (optional)type
result - an array with type type
, containing the values produced by the callback
function.Find the indices of the minimum and maximum values in this TypedArray.
Parameters:Object
results Find the minimum and maximum values of all elements in this TypedArray.
Parameters:Object
results This is a static method (it is called directly on the type, not on an object of that type, e.g.
Float64Array.readFromColumn(...)
).
Function
readFn Number
begin Number
end Number
defaultValue - (optional) If not specified, NaN is used.TypedArray
values This is a static method (it is called directly on the type, not on an object of that type, e.g.
Float64Array.readFromColumn(...)
). If any value in the column is missing, this function returns null.
TypedArray
values This is a polyfill, only added if the standard builtin method does not exist. You can read the definition of the builtin method at: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/map
Parameters: Returns:?
result - of the reductionThis is a polyfill, only added if the standard builtin method does not exist. You can read the definition of the builtin method at: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice
Parameters: Returns:type
an - array with the same type as this arrayTransform each element of the TypedArray using the given callback function. This is equivalent to the code:
for (let i = 0; i < array.length; ++i) {
array[i] = callback.call(thisArg, array[i], i, array);
}
Parameters: